// // 父

import "../../../../../../css/todolist3.css";
import { useState } from "react";
import ContextTodo from "./store/contextTodo";
import Conlist1 from "./conlist1";
import Conlist2 from "./conlist2";
const Conlist = () => {

  const [uselist, setuser] = useState({
    list: [
      {
        time: '2003-4-23',
        name: "张三",
        priority: 1
      },
      {
        time: '2003-3-19',
        name: "李四",
        priority: 2
      }
    ]
  })

  let todolist4 = (msg) => {
    // console.log(msg);
    let nlist = uselist.list //把数据重新付个变量
    nlist.push(msg)       //把传过来的数据push给初始数据
    setuser(() => {         //改变原数据
      return {
        ...uselist,
        uselist: nlist
      }
    })
  }

  return (
    <>
      <div className="todolist3">

        <ContextTodo.Provider value={{ ...uselist, todolist4 }}  >
          <Conlist1 />
          <Conlist2 />
        </ContextTodo.Provider>

      </div>
    </>
  )

}

export default Conlist;